package com.atguigu.vod.controller.front;

import com.atguigu.commonutils.R;
import com.atguigu.vod.utils.ConstantVodUtils;
import com.atguigu.vod.utils.InitVodClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author He Wentao
 * @since 2022/9/26 21:58
 */

@RestController
@RequestMapping("/eduvod/video/")
public class VodFrontVodController {

    // 根据视频id，获取视频播放凭证
    @GetMapping("/getPlayAuth/{id}")
    public R getPlayAuth(@PathVariable("id") String id) {
        try {
            return R.ok().data("playAuth", InitVodClient.getVodAuth(ConstantVodUtils.KEY_ID, ConstantVodUtils.KEY_SECRET, id));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return R.error().message("凭证获取失败");
    }

}
